package com.starblink.store.detail.uinew

import android.view.View
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.TimeUtils
import com.google.android.material.appbar.AppBarLayout
import com.starblink.android.basic.aroute.CommonRoute
import com.starblink.android.basic.base.activity.BaseTVMActivity
import com.starblink.android.basic.bean.LoadAction
import com.starblink.android.basic.brv.annotaion.DividerOrientation
import com.starblink.android.basic.brv.utils.addModels
import com.starblink.android.basic.brv.utils.bindingAdapter
import com.starblink.android.basic.brv.utils.defaultDividerStagger
import com.starblink.android.basic.brv.utils.divider
import com.starblink.android.basic.brv.utils.grid
import com.starblink.android.basic.brv.utils.models
import com.starblink.android.basic.brv.utils.setup
import com.starblink.android.basic.brv.utils.staggered
import com.starblink.android.basic.ext.click
import com.starblink.android.basic.ext.dp
import com.starblink.android.basic.ext.gone
import com.starblink.android.basic.ext.isNotAvailable
import com.starblink.android.basic.ext.toast
import com.starblink.android.basic.ext.visible
import com.starblink.android.basic.ext.visibleOrGone
import com.starblink.android.basic.extension.navigationTo
import com.starblink.android.basic.sensorsdata.extension.trackData
import com.starblink.android.basic.sensorsdata.room.entity.SkAntEntity
import com.starblink.android.basic.sensorsdata.spm.GTrackerAssistUtils
import com.starblink.android.basic.sensorsdata.spm.cfg.SpmElementDef
import com.starblink.android.basic.sensorsdata.spm.cfg.SpmPageDef
import com.starblink.android.basic.sensorsdata.spm.event.TrackEvent
import com.starblink.android.basic.sensorsdata.spm.impl.SpmTrackHandler
import com.starblink.android.basic.user.UserDataCenter
import com.starblink.android.basic.util.FlowCountDownTimer
import com.starblink.android.basic.util.bus.FlowBus
import com.starblink.android.basic.util.bus.FlowConst
import com.starblink.android.basic.util.bus.bean.CollectProductEvent
import com.starblink.android.basic.util.bus.bean.FollowStoreEvent
import com.starblink.basic.apollo.ext.ApolloValSetExt.apolloValue
import com.starblink.basic.ext.load
import com.starblink.basic.ext.screenWidth
import com.starblink.basic.log.SKLogger
import com.starblink.basic.route.RoutePage
import com.starblink.basic.style.R
import com.starblink.basic.util.CommUtils
import com.starblink.library.widget.databinding.CellSimpleProductCardBinding
import com.starblink.library.widget.product.ProductCardScene
import com.starblink.rocketreserver.FetchMerchantWebFirstEnterInfoQuery.FetchMerchantWebFirstEnterInfo
import com.starblink.rocketreserver.fragment.MerchantWebVOF
import com.starblink.rocketreserver.fragment.ProductF
import com.starblink.store.StoreManager
import com.starblink.store.databinding.ActivityStoreDetailBinding
import com.starblink.store.databinding.CellSimpleProductCardStoreDealsBinding
import com.starblink.store.databinding.CellStoreDetailRecommendEmptyBinding
import com.starblink.store.detail.bean.RvProductEntry
import com.starblink.store.detail.bean.RvRecommendEmptyEntry
import com.starblink.store.detail.view.StoreFollowDialog
import org.joda.time.DateTime
import java.text.SimpleDateFormat
import java.util.Locale
import kotlin.math.absoluteValue

/**
 * 店铺详情页
 */
@Route(path = RoutePage.Store.PAGE_HOME)
class StoreDetailActivity : BaseTVMActivity<ActivityStoreDetailBinding, StoreDetailVM>() {

    companion object {
        private val OFFSET_RETURN_BTN = CommUtils.dip2px(100)
        const val TAG = "StoreDetail"
    }

    @Autowired(name = RoutePage.Product.PRODUCT_ID)
    @JvmField
    var productId: String = ""

    @Autowired(name = RoutePage.Store.ID)
    @JvmField
    var storeId: String = ""

    /**
     * 店铺信息
     * @note 从外部传入的店铺信息，仅用于优化UI显示
     * （真实的店铺信息，需要重新加载，因为外部传入的店铺信息可能已经失效或数据发生了变化）
     * @note 该字段可能为空，部分场景，无法传入该字段
     */
    @Autowired(name = RoutePage.Store.STORE_INFO)
    @JvmField
    var storeInfo: MerchantWebVOF? = null

    override fun initViewBinding(): ActivityStoreDetailBinding =
        ActivityStoreDetailBinding.inflate(layoutInflater)

    override fun initData() {
        super.initData()
//        storeId = "8_338469194284523520" // 预发，折扣好物
//        storeId = "8_316438581231812608" // 测试，Deals
        viewModel.storeId = storeId
        SKLogger.e("dss", "Activity onCreate at ${TimeUtils.date2String(TimeUtils.getNowDate())}")
    }

    override fun initView() {
        super.initView()

        initViewTopBar()
        initViewSaleProducts()
        initViewRvRecommend()
        initViewBottomRightBtns()

        // 初始化店铺信息UI
        storeInfo?.let { showStoreInfo(it) }
    }

    private fun initViewTopBar() {
        viewBinding.layoutTopBar.layoutSearch.isEnabled = false
        viewBinding.layoutTopBar.layoutSearch.click {
            // 点击搜索栏，跳转搜索页面
            navigationTo(RoutePage.Store.PAGE_SEARCH) {
                withString(RoutePage.Store.ID, storeId)
            }
            cancelOrCloseFollowReminder()
        }
    }

    private fun initViewSaleProducts() {
        viewBinding.layoutSaleProducts.btnViewAll.click {
            navigationTo(RoutePage.Store.PAGE_DISCOUNT_PRODUCTS) {
                withObject(RoutePage.Store.STORE_INFO, viewModel.storeInfoLD.value)
            }
            // 埋点：店铺详情-折扣好物-View All点击
            it.trackData(
                page = SpmPageDef.StoreDetailPage,
                element = SpmElementDef.ELE_33009,
                params = mapOf(
                    "merchantName" to (viewModel.storeInfoLD.value?.merchantName ?: ""),
                ),
                onlyHit = true
            )
            cancelOrCloseFollowReminder()
        }

        viewBinding.layoutSaleProducts.rv.grid(3).divider {
            setDrawable(R.drawable.sp_divider_horizontal)
            orientation = DividerOrientation.GRID
        }.setup {
            // 商品卡片
            addType<ProductF, CellSimpleProductCardStoreDealsBinding>(it)

            onBind {
                val viewBinding = getBinding<CellSimpleProductCardStoreDealsBinding>()
                val model = getModel<ProductF>()

                viewBinding.card.bindProduct(
                    activity = this@StoreDetailActivity,
                    product = model,
                    trackPage = SpmPageDef.StoreDetailPage,
                    position = layoutPosition
                )
            }

            onClick(com.starblink.store.R.id.card) {
                val viewBinding = getBinding<CellSimpleProductCardStoreDealsBinding>()
                val model = getModel<ProductF>()
                cancelOrCloseFollowReminder()
                StoreManager.navigationToProductWebPage(mActivity, model)
            }
        }
    }

    private fun initViewRvRecommend() {
        viewBinding.rvRecommend.staggered(2).defaultDividerStagger().setup {
            addType<ProductF, CellSimpleProductCardBinding>(it) // 商品卡片
            addType<RvRecommendEmptyEntry, CellStoreDetailRecommendEmptyBinding>(it) // 空视图

            onBind {
                when (itemViewType) {
                    com.starblink.library.widget.R.layout.cell_simple_product_card -> {
                        val vb = getBinding<CellSimpleProductCardBinding>()
                        val model = getModel<ProductF>()

                        vb.card.scene = ProductCardScene.STORE_RECOMMEND
                        vb.card.bindProduct(
                            refreshLayout = viewBinding.pageRefreshLayout,
                            recyclerView = viewBinding.rvRecommend,
                            productWrap = RvProductEntry(layoutPosition, model),
                            position = layoutPosition,
                            spmPageValue = SpmPageDef.StoreDetailPage,
                            onItemClickListener = {
                                cancelOrCloseFollowReminder()
                            },
                            guideType = TAG
                        )
                    }

                    com.starblink.store.R.layout.cell_store_detail_recommend_empty -> {
                        val viewBinding = getBinding<CellStoreDetailRecommendEmptyBinding>()
                        val model = getModel<RvRecommendEmptyEntry>()
                        // 占满一行
                        viewBinding.root.layoutParams =
                            (viewBinding.root.layoutParams as StaggeredGridLayoutManager.LayoutParams).apply {
                                isFullSpan = true
                            }
                    }
                }
            }
        }
//        viewBinding.pageRefreshLayout.onError {
//            post {
//                setEmptyViewForWishTemplate(
//                    title = "Oops!",
//                    subTitle = "Sorry, no products have been found.",
//                    marginTop = 37.dp,
//                )
//            }
//        }

        viewBinding.pageRefreshLayout.onLoadMore {
            viewModel.loadMoreRecommendProducts()
        }
    }

    private fun initViewBottomRightBtns() {
        // 点击心愿单按钮，跳转到首页心愿单
        viewBinding.vWishList.setOnClickListener {
            FlowBus.intFlowBusNotify(FlowConst.WISH_INDEX_CHANGE, 3)
        }

        // 返回顶部按钮
        viewBinding.appBarLayout.addOnOffsetChangedListener { appBarLayout: AppBarLayout, verticalOffset: Int ->
            // 页面内容滑动距离大于OFFSET时，显示按钮
            viewBinding.vReturnTop.visibleOrGone(verticalOffset.absoluteValue > OFFSET_RETURN_BTN)
        }
        viewBinding.vReturnTop.setOnClickListener {
            val behavior =
                (viewBinding.appBarLayout.layoutParams as CoordinatorLayout.LayoutParams).behavior
            if (behavior is AppBarLayout.Behavior) {
                val topAndBottomOffset = behavior.topAndBottomOffset
                if (topAndBottomOffset != 0) {
                    behavior.topAndBottomOffset = 0
                    viewBinding.rvRecommend.scrollToPosition(0);
                }
            }
        }
    }

    override fun initObservable() {
        super.initObservable()
        viewModel.storeInfoLD.observe(this) {
            showStoreInfo(it)
        }
        viewModel.storeFirstEnterInfoLD.observe(this) {
            showFollowStoreDialogOrReminderPopup(it)
        }
        viewModel.pageRefreshDataLD.observe(this) {
            showStoreDeals(it.storeDeals)
            showSaleProducts(it.saleProducts)
            showRecommendProducts(it.recommendProducts)
            showContent()
        }
        viewModel.loadMoreRecommendProductLD.observe(this) {
            if (it == null) {
                // 接口异常，结束加载
                viewBinding.pageRefreshLayout.finish(false)
                return@observe
            }
            viewBinding.pageRefreshLayout.addData(data = it) {
                it.isNotEmpty()
            }
        }
        viewModel.mLoadActionLiveData.observe(this) {
            when (it.action) {
                LoadAction.STATE_ERROR -> {
                    showError(it.errorCode)
                }
            }
        }

        initEvents()
    }

    private fun initEvents() {
        // 事件处理：关注店铺事件
        FlowBus.with<FollowStoreEvent>(FlowConst.FOLLOW_STORE_EVENT).register(this) { event ->
            FlowCountDownTimer(time = 1).start(
                callBack = {},
                onFinish = {
                    if (event.id != null && event.id == storeId && viewModel.storeInfoLD.value != null
                        && event.followed != viewModel.storeInfoLD.value!!.subOrNot
                    ) {
                        StoreManager.refreshFollowData(
                            viewModel.storeInfoLD.value!!,
                            viewBinding.layoutStoreInfo
                        )
                    }
                })
        }
    }

    override fun initLoad() {
        super.initLoad()
//        //        storeId = "8_317925622822600704"
//        viewModel.loadStoreDetail(storeId ?: "")
        loadPageData()
    }


    var onlyExposure = true

    private fun showStoreInfo(merchant: MerchantWebVOF) {
        if (onlyExposure) {
            onlyExposure = false
            pageExposure(
                SpmPageDef.StoreDetailPage,
                mapOf(
                    "merchantName" to "${merchant.merchantName}"
                )
            )
        }

        if (merchant.logo.isNullOrEmpty()) {
            StoreManager.showStoreTextIcon(merchant, viewBinding.layoutStoreInfo)
        } else {
            viewBinding.layoutStoreInfo.ivStoreIcon.load(merchant.logo, errorCall = {
                StoreManager.showStoreTextIcon(merchant, viewBinding.layoutStoreInfo)
            })
        }

        viewBinding.layoutStoreInfo.tvTitle.text = merchant.merchantName
        viewBinding.layoutStoreInfo.ivStoreIcon.click {
            StoreManager.navigationToStoreWebPage(merchant)
            cancelOrCloseFollowReminder()
        }
        viewBinding.layoutStoreInfo.tvTitle.click {
            StoreManager.navigationToStoreWebPage(merchant)
            cancelOrCloseFollowReminder()
        }

        viewBinding.layoutStoreInfo.tvSubscribers.text = "${merchant.subNum} Followers"
        viewBinding.layoutStoreInfo.tvSubscribers.visible()

        StoreManager.setFollowState(merchant.subOrNot, merchant.subNum, viewBinding.layoutStoreInfo)
        viewBinding.layoutStoreInfo.vFollow.run {
            trackData(
                page = SpmPageDef.StoreDetailPage,
                element = SpmElementDef.HomeNewSubStoreSmallAdd,
                onlyHit = true,
                params = mapOf(
                    "merchantName" to "${merchant.merchantName}",
                    "status" to (if (UserDataCenter.isLogin()) "1" else "0"),
                    "result" to "${if (merchant?.subOrNot == true) "0" else "1"}"
                )
            )
            click {
                cancelOrCloseFollowReminder()
                StoreManager.followStore(
                    merchant,
                    mActivity,
                    lifecycleScope,
                    viewBinding.layoutStoreInfo
                )
            }
        }
    }

    // 显示店铺Deals模块
    private fun showStoreDeals(merchant: MerchantWebVOF?) {
        // 数据异常，不显示该模块
        if (merchant == null) {
            viewBinding.layoutStoreDeals.root.gone()
            return
        }

        viewBinding.layoutStoreDeals.root.visibleOrGone(true) {
            // 埋点：deals模块曝光
            trackData(
                page = SpmPageDef.StoreDetailPage,
                element = SpmElementDef.Element_33008,
                params = mapOf("merchantName" to (viewModel.storeInfoLD.value?.merchantName ?: "")),
            )
        }
        viewBinding.layoutStoreDeals.layoutCouponCode.visibleOrGone(
            merchant.hasCouponCode == true && merchant.couponCode.isNullOrEmpty().not()
        ) {
            viewBinding.layoutStoreDeals.tvCouponCode.text = "${merchant.couponCode}"
            viewBinding.layoutStoreDeals.btnCopy.click {
                CommUtils.copyText(merchant.couponCode)
                toast("Copy Successfully")
            }
        }
        viewBinding.layoutStoreDeals.tvTitle.text = "Shop with ${merchant.discount ?: 0}% off"
        viewBinding.layoutStoreDeals.tvTime.text =
            "Valid Until: ${
                TimeUtils.date2String(
                    DateTime(merchant.endTime).toDate(),
                    SimpleDateFormat("MMM dd, yyyy", Locale.ENGLISH)
                )
            }"

        fun navigationToStoreOriginPage(view: View) {
            navigationToStoreOriginPage(merchant)
            // 埋点：Deals模块点击
            view.trackData(
                page = SpmPageDef.StoreDetailPage,
                element = SpmElementDef.Element_33008,
                params = mapOf("merchantName" to (viewModel.storeInfoLD.value?.merchantName ?: "")),
                onlyHit = true
            )
            cancelOrCloseFollowReminder()
        }

        viewBinding.layoutStoreDeals.tvDescription.initWidth(screenWidth - 48.dp)
        viewBinding.layoutStoreDeals.tvDescription.maxLines = 2
        viewBinding.layoutStoreDeals.tvDescription.setHasAnimation(true)
        viewBinding.layoutStoreDeals.tvDescription.setCloseInNewLine(true)
        viewBinding.layoutStoreDeals.tvDescription.setCloseSuffix(" Hide")
        viewBinding.layoutStoreDeals.tvDescription.setOpenSuffixColor(CommUtils.getColor(com.starblink.basic.style.R.color.gu_text_data_blue))
        viewBinding.layoutStoreDeals.tvDescription.setCloseSuffixColor(CommUtils.getColor(com.starblink.basic.style.R.color.gu_text_data_blue))
        viewBinding.layoutStoreDeals.tvDescription.setOnTextClickListener() {
            navigationToStoreOriginPage(it)
        }
        viewBinding.layoutStoreDeals.tvDescription.setOriginalText(
            merchant.merchantDesc
        )

        viewBinding.layoutStoreDeals.tvTitle.click { navigationToStoreOriginPage(it) }
        viewBinding.layoutStoreDeals.tvTime.click { navigationToStoreOriginPage(it) }
        viewBinding.layoutStoreDeals.btnShopNow.click { navigationToStoreOriginPage(it) }
    }

    // 显示折扣商品模块
    private fun showSaleProducts(saleProducts: List<ProductF>?) {
        // 数据异常，不显示该模块
        if (saleProducts.isNullOrEmpty() || saleProducts.size < 6) {
            viewBinding.layoutSaleProducts.root.gone()
            return
        }

        viewBinding.layoutSaleProducts.root.visible()
        viewBinding.layoutSaleProducts.rv.addModels(saleProducts.take(6))
    }

    private fun showRecommendProducts(recommendProducts: List<Any>) {
        viewBinding.pageRefreshLayout.addData(data = recommendProducts) {
            recommendProducts.isNotEmpty()
        }
    }

    /**
     * 显示订阅店铺弹窗或者订阅店铺提醒Popup
     */
    private fun showFollowStoreDialogOrReminderPopup(storeFirstEnterInfo: FetchMerchantWebFirstEnterInfo?) {
        if (storeFirstEnterInfo != null && storeFirstEnterInfo.firstEnter && !storeFirstEnterInfo.hasSub) {
            // 当成功获取接口数据+首次进入店铺+未订阅过店铺时，显示弹窗
            val dialog =
                navigationTo(RoutePage.Store.DIALOG_STORE_FOLLOW) {
                    withString(
                        RoutePage.Store.STORE_NAME,
                        viewModel.storeInfoLD.value?.merchantName
                    )
                } as StoreFollowDialog
            dialog.show(supportFragmentManager, "StoreFollowDialog")
            // 埋点：店铺主页-订阅提醒弹窗，显示
            SpmTrackHandler.addSingleTrackData(
                SkAntEntity(
                    event = TrackEvent.elementExposure.value,
                    spmCnt = GTrackerAssistUtils.fetchElementValue(
                        SpmPageDef.StoreDetailPage,
                        SpmElementDef.Element_33082
                    ),
                    params = mapOf(
                        "merchantName" to (viewModel.storeInfoLD.value?.merchantName ?: ""),
                        "status" to if (UserDataCenter.isLogin()) "1" else "0"
                    ),
                )
            )
            supportFragmentManager.setFragmentResultListener(
                StoreFollowDialog.RESULT_FOLLOW_STORE, this
            ) { _, bundle ->
                if (bundle.getBoolean(StoreFollowDialog.KEY_RESULT, false)) {
                    // 关注店铺
                    viewModel.storeInfoLD.value?.let {
                        StoreManager.followStore(
                            it,
                            mActivity,
                            lifecycleScope,
                            viewBinding.layoutStoreInfo
                        )
                    }
                }
            }
        } else if (viewModel.storeInfoLD.value?.subOrNot == false) {
            // 当前店铺未订阅，10S后显示订阅提醒弹窗
            startCountDownTimerForShowFollowReminder()
        }
    }

    // <editor-fold desc="关注提醒视图">
    var countDownTimerForShowFollowReminder = FlowCountDownTimer(time = 8) // 显示订阅提醒倒计时
    var countDownTimerForCloseFollowReminder = FlowCountDownTimer(time = 5) // 关闭订阅提醒倒计时

    /**
     * 10S后显示关注提醒视图
     */
    private fun startCountDownTimerForShowFollowReminder() {
        countDownTimerForShowFollowReminder.start(callBack = {},
            onFinish = {
                showFollowReminder()
            })
    }

    /**
     * 4S后关闭关注提醒视图
     */
    private fun startCountDownTimerForCloseFollowReminder() {
        countDownTimerForCloseFollowReminder.start(callBack = {},
            onFinish = {
                cancelOrCloseFollowReminder()
            })
    }

    /**
     * 显示关注提醒视图
     */
    private fun showFollowReminder() {
        viewModel.storeInfoLD.value?.let {
            if (isNotAvailable()) {
                return@let
            }
            // 埋点：店铺主页-订阅引导浮层 点击/曝光
            viewBinding.layoutFollowReminder.btnFollow.trackData(
                page = SpmPageDef.StoreDetailPage,
                element = SpmElementDef.Element_33085,
                params = mapOf(
                    "merchantName" to (viewModel.storeInfoLD.value?.merchantName ?: ""),
                    "status" to (if (UserDataCenter.isLogin()) "1" else "0"),
                )
            )
            viewBinding.layoutFollowReminder.ivStoreIcon.load(it.logo, it.merchantName)
            viewBinding.layoutFollowReminder.btnFollow.click { view ->
                cancelOrCloseFollowReminder()
                StoreManager.followStore(it, mActivity, lifecycleScope, viewBinding.layoutStoreInfo)
            }
            viewBinding.layoutFollowReminder.root.visible()
            startCountDownTimerForCloseFollowReminder()
            SKLogger.e(
                "dss",
                "FollowReminder show at ${TimeUtils.date2String(TimeUtils.getNowDate())}"
            )
        }
    }

    /**
     * 取消或关闭关注视图
     */
    private fun cancelOrCloseFollowReminder() {
        if (isNotAvailable()) {
            return
        }
        countDownTimerForShowFollowReminder.cancel()
        countDownTimerForCloseFollowReminder.cancel()
        viewBinding.layoutFollowReminder.root.gone()
    }
    // </editor-fold>

    private fun loadPageData() {
        showLoading()
        viewModel.loadPageData()
    }

    private fun showLoading() {
        viewBinding.layoutLoading.root.visible()
        viewBinding.errorView.gone()
        viewBinding.layoutStoreDeals.root.gone()
        viewBinding.layoutSaleProducts.root.gone()
        viewBinding.layoutRecommend.gone()
        viewBinding.pageRefreshLayout.gone()
        viewBinding.vWishList.gone()
        viewBinding.layoutTopBar.layoutSearch.isEnabled = false
        viewBinding.layoutTopBar.tvSearch.isEnabled = false
        viewBinding.layoutTopBar.ivSearch.isEnabled = false
        viewBinding.layoutStoreInfo.vFollow.isEnabled = false
        viewBinding.layoutStoreInfo.ivStoreIcon.isEnabled = false
        viewBinding.layoutStoreInfo.tvTitle.isEnabled = false
    }

    private fun showContent() {
        viewBinding.layoutLoading.root.gone()
        viewBinding.errorView.gone()
//        viewBinding.layoutStoreInfo.tvFollow.visible()
//        viewBinding.layoutStoreDeals.root.visible()
//        viewBinding.layoutSaleProducts.root.visible()
        viewBinding.layoutRecommend.visible()
        viewBinding.pageRefreshLayout.visible()
        viewBinding.vWishList.visible()
        viewBinding.layoutTopBar.layoutSearch.isEnabled = true
        viewBinding.layoutTopBar.tvSearch.isEnabled = true
        viewBinding.layoutTopBar.ivSearch.isEnabled = true
        viewBinding.layoutStoreInfo.vFollow.isEnabled = true
        viewBinding.layoutStoreInfo.ivStoreIcon.isEnabled = true
        viewBinding.layoutStoreInfo.tvTitle.isEnabled = true
    }

    // 显示错误提示页
    private fun showError(errorCode: Int) {
        viewBinding.layoutLoading.root.gone()
        viewBinding.errorView.visible()

        when (errorCode) {
            StoreDetailVM.ERROR_GET_STORE_INFO_FAIL -> {
                viewBinding.errorView.text2 = "Store load failed"
                viewBinding.errorView.btnShown = true
                viewBinding.errorView.btnText = "Refresh"
                viewBinding.errorView.onBtnClick = {
                    loadPageData()
                }
            }

            StoreDetailVM.ERROR_STORE_INVALID -> {
                viewBinding.errorView.text2 = "The store is not available"
            }
        }
    }

    //跳转店铺原网站
    private fun navigationToStoreOriginPage(model: MerchantWebVOF) {
        CommonRoute.startStoreLinkWithCode(
            model.merchantWebNo,
            model.merchantWebUrl,
            model.couponCode ?: "",
            model.merchantDiscountInfo
        )
    }


    override fun onPause() {
        pageDisappear(SpmPageDef.StoreDetailPage)
        super.onPause()
    }
}